package net;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Klasa odczytu danych ze strumienia 
 * @author adrian
 */
public class Reader extends Thread{
    Connector connector;
    BufferedReader reader;    

    public Reader(Connector connector) throws IOException {
        this.connector = connector;
        reader = new BufferedReader(new InputStreamReader(connector.getSocket().getInputStream()));
        
    }
    
    
    /**
     *
     * @Override
     * */
    public void run() {
        String currentLine;
        System.out.println("Reader.run()");
        try {
            while ((currentLine = reader.readLine()) != null) {
                connector.getIrcClient().receivedCommand(currentLine);
            }
        } catch (Exception ex) {
            Logger.getLogger(Connector.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
}
